import * as React from 'react'
import * as ReactDOM from 'react-dom'
import style from './style.module.css'

function Toast(text: string) {
  let el = document.createElement('div')
  document.body.appendChild(el)
  ReactDOM.render(<div className={style.wrap}>
    <div className={style.box}>{text}</div>
  </div>, el)
  setTimeout(() => {
    ReactDOM.unmountComponentAtNode(el)
    document.body.removeChild(el)
  }, 2000)
}

export default Toast